<?php

class Admin_Form_Post extends Zend_Form
{

    public function init()
    {
        $this->setMethod("post");
        $this->setAttrib('class', 'validate-form');
        
        $this->addElement('select','cbbMenu2',array(
        										'label'			=>	'Menu 2',
        										'required'		=> true,
        										'class'			=> "required",
        										'multiOptions'	=> $this->getAllMenu2()
        									)
        		);
        		
        $this->addElement('text','txtTieuDe',array(
        										'label'		=>	'Tiêu đề',
        										'required'	=> true,
        										'class'		=> "required",
        										'maxlength' => 200
        									)
        		);
        
        $this->addElement('file','fHinh',array(
        								'label'		=> "Hình ảnh",
        								
        							)
        		);
        		
        $this->addElement('textarea','tAreaNoiDung',array(
        										'label'		=>	'Nội dung',
        										'required'	=> true,
        										'class'		=> "required tinyMceNoiDung",
        										'rows'		=> 20,
        										'cols'		=> 50,
        										'id'		=> 'tinnyMCENoiDung'
        									)
        		);
        
        $this->addElement('select','cbbTrangThai',array(
        										'label'		=>	'Đăng bài',
        										'required'	=> true,
        										'class'		=> "required",
        										'multiOptions'=> array(
        												'0'	=> "Không đăng bài",
        												'1' => "Đăng bài"
        										)
        									)
        		);
    }

	/**
     * 
     * Set action cho form
     * @param unknown_type $actionName: ten cua action
     */
    function addAction($module,$controller, $actionName){
    	$this->setAction(Zend_Controller_Front::getInstance()->getBaseUrl()."/".$module."/".$controller."/".$actionName);
    }
    
    /**
     * 
     * Add nut submit 
     */
    function addSubmitButton($name, $label){
    	$this->addElement('submit',$name,array(
    						'label'		=>	$label,
    						'decorators'=>	array('ViewHelper',array('HtmlTag',array(
    																			'tag' => 'dd' //giu nguyen the dd ko them bat cu the j
    																		)
    														
    															)
    							
    										),
    						'class'		=>	'input-hover uSubmit'	
    					));
    	
    }
    
    function addHiddenId($name,$value){
    	$this->addElement('hidden',$name,array(
			    				'value'	=> $value	
    						));
    }
    

	private function getAllMenu2(){
    	$menu2 = new Admin_Model_Menu2();
    	$menu2 = $menu2->fetchAllMenu2();
    	$arrData = array();
    	$arrData[0] = "Giới thiệu";
    	foreach ($menu2 as $value) {
    		$arrData[$value['menu2Id']] =$value['tenMenu2']	;
    	}
    	return $arrData;
    }
    
    
    
}

